<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on March 12, 2009 at 5:47:27 pm</time-stamp>


<class>
<name>CCSTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>ccs r1 r2 s1 s2 i1 i2 l1 l2 it1 it2 it3 it4 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.CCSTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.CCSTest</class-id>
<body>This is an SUnit test class for the CCS Class

Instance Variables:
	ccs	&lt;CCS&gt;	A CCS Instance to run tests on

</body>
</comment>

<methods>
<class-id>SupplyChain.CCSTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="ccs">ccs
	^ccs</body>

<body package="SupplyChain" selector="ccs:">ccs: anObject
	ccs := anObject</body>

<body package="SupplyChain" selector="i1">i1
	^i1.</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1:= anObject.</body>

<body package="SupplyChain" selector="it1">it1
	^it1.</body>

<body package="SupplyChain" selector="it1:">it1: anObject
	it1:= anObject.</body>

<body package="SupplyChain" selector="it2">it2
	^it2.</body>

<body package="SupplyChain" selector="it2:">it2: anObject
	it2:= anObject.</body>

<body package="SupplyChain" selector="it3">it3
	^it3.</body>

<body package="SupplyChain" selector="it3:">it3: anObject
	it3:= anObject.</body>

<body package="SupplyChain" selector="it4">it4
	^it4.</body>

<body package="SupplyChain" selector="it4:">it4: anObject
	it4:= anObject.</body>

<body package="SupplyChain" selector="l1">l1
	^l1.</body>

<body package="SupplyChain" selector="l1:">l1: anObject
	l1:= anObject.</body>

<body package="SupplyChain" selector="r1">r1
	^r1.</body>

<body package="SupplyChain" selector="r1:">r1: anObject
	r1:= anObject.</body>

<body package="SupplyChain" selector="s1">s1
	^s1.</body>

<body package="SupplyChain" selector="s1:">s1: anObject
	s1:= anObject.</body>
</methods>

<methods>
<class-id>SupplyChain.CCSTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="addAllItems">addAllItems
   "utility method to add all the items to the inventories and lots"
   i1 addItem: it1.
   i1 addItem: it2.
   l1 addItem: it1.
   l1 addItem: it2.
   i2 addItem: it3.
   i2 addItem: it4.
   l2 addItem: it3.
   l2 addItem: it4.
   s1 inventory: i1.
   s1 lots: l1.
   s2 inventory: i2.
   s2 lots: l2.</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	ccs := CCS new.
	r1 := nil.
	r2 := nil.
	s1 := nil.
	s2 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.CCSTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="setUp">setUp
	r1 := Retailer new.
	r1 location: 'Home Depot'.
	r1 number: '1'.
	r2 := Retailer new.
	r1 location: 'Home Depot'.
	r1 number: '2'.
	s1 := Supplier new.
	s1 name: 'Super People'.
	s2 := Supplier new.
	s2 name: 'Less So'.
	i1 := Inventory new.
	i2 := Inventory new.
	l1 := Lot new.
	l2 := Lot new.
  	it1 := Item named: 'Video Game' sku:'89X999'.
  	it2 := Item named: 'TV' sku: '99Z837'.
  	it3 := Item named: 'VCR' sku: '54Y3632'.
  	it4 := Item named: 'PC' sku: '01P6373'.
	^self.</body>

<body package="SupplyChain" selector="testAddRetailer">testAddRetailer
	ccs addRetailer: r1.
	self assert: (ccs retailers includes: r1).</body>

<body package="SupplyChain" selector="testAddSupplier">testAddSupplier
	ccs addSupplier: s1.
	self assert: (ccs suppliers includes: s1).</body>

<body package="SupplyChain" selector="testDeepCopy">testDeepCopy
	|copy|
	copy := ccs deepCopy.
	self assert: (ccs retailers = copy retailers).
	self assert: (ccs suppliers = copy suppliers).</body>

<body package="SupplyChain" selector="testHandleOrder">testHandleOrder
	|order items|
	order := Order new.
	items := OrderedCollection new.
	items add: it1.
	items add: it2.
	order items: items.
	order retailer: r1.
	self addAllItems.
      ccs addSupplier: s1.
	ccs addRetailer: r1.
	ccs handleOrder: order.
	self assert: (((r1 orderedItemsList at: 1) printString) = (it2 printString)).
	self assert: (((r1 orderedItemsList at: 2) printString) = (it1 printString)).</body>

<body package="SupplyChain" selector="testLoad">testLoad
	ccs addSupplier: s1.
	ccs addRetailer: r1.
	ccs save.
	ccs load.
	self assert: (((ccs suppliers at: 1) name) = s1 name).
	self assert: (((ccs retailers at: 1) location) = r1 location).</body>

<body package="SupplyChain" selector="testRemoveRetailer">testRemoveRetailer
	ccs addRetailer: r1.
	ccs removeRetailer: r1.
	self deny: (ccs retailers includes: r1).</body>

<body package="SupplyChain" selector="testRemoveSupplier">testRemoveSupplier
	ccs addSupplier: s1.
	ccs removeSupplier: s1.
	self deny: (ccs suppliers includes: s1).</body>

<body package="SupplyChain" selector="testSave">testSave
	self addAllItems.
	ccs addSupplier: s1.
	ccs addRetailer: r1.
	ccs save.
	ccs load.
	self assert: (((ccs suppliers at: 1) name) = s1 name).
	self assert: (((ccs retailers at: 1) location) = r1 location).</body>

<body package="SupplyChain" selector="testUpdateWith">testUpdateWith
	|ccs2|
	ccs2 := CCS new.
	ccs addRetailer: r1.
	ccs addSupplier: s1.
	ccs2 addRetailer: r2.
	ccs2 addSupplier: s2.
	ccs updateWith: ccs2.
	self deny: ((ccs retailers) includes: r1).
	self deny: ((ccs suppliers) includes: s1).</body>
</methods>

</st-source>
